#define _CRT_SECURE_NO_WARNINGS

//#include"sort.h"
//void PrintArray(int* a, int n) {
//	for (int i = 0; i < n; i++) {
//		printf("%d ", a[i]);
//	}
//	printf("\n");
//}
////int main() {
////	int a[] = { 5,0,4,2,3,1,6,7,9,8 };
////	SelectSort(a, sizeof(a) / sizeof(a[0]));
////	PrintArray(a, 10);
////	return 0;
////}
//void Add(int x, int y);
//int main() {
//	Add(1, 2);
//	return 0;
//}
#include<stdio.h>
#include"sort.h"
int main() {
	int a[] = { 2,1,5,9,2,2,2,2,3,6,4,7,8,2,5,2,3,2,5,4,2,5,8,2,2,3,2,4,2,5,6,2,2,2,9 };
	int n = sizeof(a) / sizeof(a[0]);
	int left = 0;
	int cur = left + 1;
	int right = n - 1;
	int key = a[left];
	while (cur <= right) {
		if (a[cur] < key) {
			Swap(&a[left], &a[cur]);
			left++;
			cur++;
		}
		else if (a[cur] == key) {
			cur++;
		}
		else {
			Swap(&a[cur], &a[right]);
			right--;
		}
	}
	QuickSort3(a, 0, left - 1);
	QuickSort3(a, right + 1, n - 1);
	for (int i = 0; i < n; i++) {
		printf("%d ", a[i]);
	}
	return 0;
}